Fix zero-fee tipping and add edge case test#182
Merged
Conversation
Guard the fee stx-transfer? call with a check for fee > 0. Previously, setting fee-basis-points to 0 would cause tips to fail because stx-transfer? rejects zero-amount transfers.
Confirm that when fee-basis-points is set to 0, sending a tip produces only one STX transfer event with the full amount going to the recipient and no fee transfer to the contract owner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a bug where tips would fail when platform fees are set to 0, and add a test covering this edge case.
Problem
stx-transfer?in Clarity rejects 0-amount transfers. Whenfee-basis-pointswas set to 0, the fee transfer call would fail, making tipping impossible.Fix
Guard the fee transfer with a
(> fee u0)check, skipping it entirely when no fee is charged.Test
Verify that a 1,000,000 uSTX tip with 0% fee produces exactly one transfer event with the full amount going to the recipient.
All 35 tests pass.
Closes #72